package com.xxxx.yebserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xxxx.yebserver.common.page.PageUtils;
import com.xxxx.yebserver.common.page.Query;
import com.xxxx.yebserver.entity.Employee;
import com.xxxx.yebserver.mapper.EmployeeMapper;
import com.xxxx.yebserver.service.EmployeeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cxq
 * @since 2021-06-15
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {
    @Override
    public PageUtils getEmployee(Map<String, Object> map) {
        QueryWrapper<Employee> wr = new QueryWrapper<>();
        String keyword = (String) map.get("keyword");
        //TODO 通过前端需要传递查询参数
        if(StringUtils.isNotBlank(keyword)){
            wr.like("name",keyword);
        }
        IPage<Employee> page = this.page(new Query<Employee>().getPage(map),wr);
        return new PageUtils(page);
    }
}
